﻿using System;
using System.Collections.Specialized;
using LightPersist.Transactions;

namespace LightPersist
{
	static class NotifyCollectionArgsFactory
	{
//		public NotifyCollectionChangedEventArgs Get { get; private set; }
//
//		public static NotifyCollectionArgsFactory CreateInsert(ListPropertyChangedAction lpcAction)
//		{
//			return CreateInsert(lpcAction.InsertedOrRemovedItem, lpcAction.Index);
//		}
//
		public static NotifyCollectionChangedEventArgs CreateInsert(object item, int index)
		{
			return new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index);
		}

//		public static NotifyCollectionChangedEventArgs CreateRemove(ListPropertyChangedAction lpcAction)
//		{
//			return CreateRemove(lpcAction.InsertedOrRemovedItem, lpcAction.Index);
//		}

		public static NotifyCollectionChangedEventArgs CreateRemove(object item, int index)
		{
			return new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index);
		}

//		public static NotifyCollectionArgsFactory Create(ListPropertyChangedAction lpcAction, bool undo)
//		{
//			bool isInsert_OrRemove;
//			switch (lpcAction.ListChangedAction)
//			{
//				case ListChangedAction.Insert:
//					isInsert_OrRemove = true;
//					break;
//				case ListChangedAction.Remove:
//					isInsert_OrRemove = false;
//					break;
//				default:
//					throw new InvalidOperationException();
//			}
//
//			if (undo)
//			{
//				isInsert_OrRemove = !isInsert_OrRemove;
//			}
//
//			if (isInsert_OrRemove)
//			{
//				return CreateInsert(lpcAction.InsertedOrRemovedItem, lpcAction.Index);
//			}
//			else
//			{
//				return CreateRemove(lpcAction.InsertedOrRemovedItem, lpcAction.Index);
//			}
	//	}
	}
}
